import { fetchChannelAPI } from "@/apis/list";
import type { ChannelItem } from "@/apis/list";
import { useEffect, useState } from "react";

function useFetchChannel() {
    const [channelList, setChannelList] = useState<ChannelItem[]>([])
    useEffect(() => {
        function getChannels() {
            fetchChannelAPI().then(res => {
                setChannelList(res.data.channels)
            }).catch(err => {
                console.log(err)
            })
        }
        getChannels()
    }, [])
    return channelList
}

export default useFetchChannel